//
//  MarketTableViewCell.m
//  bitcoin
//
//  Created by  旺链 on 2018/5/23.
//  Copyright © 2018年 比特币. All rights reserved.
//

#import "MarketTableViewCell.h"

@implementation MarketTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    //self.increaseLb.backgroundColor = [UIColor colorWithHexString:@"#2CB25A"];
    // Configure the view for the selected state
    if (selected) {
        NSString *str = self.data[@"upsAndDowns"];
        if ([str containsString:@"-"]) {
            //下降
            self.increaseLb.backgroundColor = [UIColor colorWithHexString:@"#2CB25A"];
        }else if(str.floatValue == 0){
            
            self.increaseLb.backgroundColor = [UIColor lightGrayColor];
        } else{
            //上升
            self.increaseLb.backgroundColor = [UIColor colorWithHexString:@"#E1454F"];
        }
    }
}
- (void)configData:(NSDictionary*)dic
{
    self.data = dic;
    
    self.currencyRelationLb.text = dic[@"currencyRelation"];
    self.priceLb.text = dic[@"price"];
    self.increaseLb.text = dic[@"upsAndDowns"];
    
    self.favBtn.selected = [dic[@"flagFav"]integerValue]==0?NO:YES;
    
    NSString *str = dic[@"upsAndDowns"];
    if ([str containsString:@"-"]) {
    //下降
        self.increaseLb.backgroundColor = [UIColor colorWithHexString:@"#2CB25A"];
    }else if(str.floatValue == 0){
        
        self.increaseLb.backgroundColor = [UIColor lightGrayColor];
    }else{
    //上升
        self.increaseLb.backgroundColor = [UIColor colorWithHexString:@"#E1454F"];
    }
}

- (IBAction)collectClick:(UIButton*)sender {
//    sender.selected = !sender.selected;
    
    if (self.favClick) {
        self.favClick();
    }
}

@end
